#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc,char **argv)
{
    if(argc < 2){
        fprintf(stderr,"Usage: %s <file>",argv[0]);
        exit(1);
    }
    FILE *fp;
    char *linebuf;
    size_t linesize;
    fp = fopen(argv[1],"r");
    if(fp == NULL){
        perror("fopen()");
        exit(1);
    }

    // 初始化非常重要
    linebuf = NULL;
    linesize = 0;


    while(1){
        if(getline(&linebuf,&linesize,fp) < 0)
            break;
        printf("%d\n",strlen(linebuf));
        printf("%d\n",linesize);
    }
    

    fclose(fp);

    exit(0);
}